<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>综合练习1</title>
    <script src="https://unpkg.com/vue@3"></script>
</head>
<body>
    <div id="app">
        <input @click="vip=!vip" type="checkbox" v-model="vip">是否会员
        <select v-show="vip" v-model="level">
            <option value="钻石">钻石会员</option>
            <option value="黄金">黄金会员</option>
            <option value="青铜">青铜会员</option>
        </select>
        <p>{{level}}会员欢迎你</p>
        数量：<input type="text" v-model="count"><br>
        单价：<input type="text" v-model="price"><br>
        <div>尊敬的{{level}},你购买的数量是{{count}}，单价是{{price}}，
            折扣是{{discount}},总价是{{count*price*discount}}元
        </div>
    </div>
</body>
</html>
<script>
    const connApp = Vue.createApp({
        data() {
            return {
                vip:false,
                count:0,
                price:0,
                discount:1,
                level:''
            }
        },
        watch:{
            level(level1){
                if(level1 == '钻石')
                {
                    alert("钻石会员欢迎你");
                    this.discount=0.5;
                }else if(level1 == '黄金')
                {
                    alert("黄金会员欢迎你");
                    this.discount=0.8;
                }else
                {
                    alert("青铜会员欢迎你");
                    this.discount=0.9;
                }
            }
        }
    }).mount("#app")
</script>